package stateAAs {
	import flash.geom.Point;
	import org.agony2d.gpu.core.ImageAA;
	import org.agony2d.gpu.core.NodeAA;
	import org.agony2d.gpu.FusionAA;
	import org.agony2d.gpu.StateAA;
	import org.agony2d.gpu.TingedImageAA;
	import org.agony2d.input.ATouchEvent;
	import org.agony2d.input.TouchManager;
	import org.agony2d.notify.AEvent;
	
public class Interact_StateAA extends StateAA {
  
	
	/** overwritable... */
	override public function get smoothing() : Boolean {
		return true
	}
	
	/** overwritable... */
	override public function get tinted() : Boolean {
		return true
	}
	
	/** overwrite... */
	override public function get fullTex() : String {
		return "atlas"
	}
	
	/** overwrite... */
	override public function enter() : void {
		{
			mFusion = new FusionAA
			this.group.addNode(mFusion)
			mFusion.x = 100
			mFusion.rotation = 10
			
			{
				img = new TingedImageAA
				mFusion.addNode(img)
				img.textureData = "flight_1"
				//img.x = -1
				img.y = 0
				//img.scaleX  = -1
				img.rotation = 30
				//img.pivotX = img.pivotY = 50
				
				img = new TingedImageAA
				mFusion.addNode(img)
				img.textureData = "flight_2"
				img.x = 200
				img.y = 200
				img.pivotX = 110
				img.scaleX  = -1
				//img.rotation = 30
				//img.pivotX = img.pivotY = 50
				
				img = new TingedImageAA
				mFusion.addNode(img)
				img.textureData = "flight_3"
				img.x = img.y = 300
				img.rotation = 30
				img.pivotX = img.pivotY = 50
				//img.scaleX = img.scaleY = 1.2
				
				
				img = new TingedImageAA
				mFusion.addNode(img)
				img.textureData = "flight_4"
				img.x = 300
				img.y = 100
				img.setCollisionMethod(onCollision)
				
				img.addEventListener(AEvent.PRESS, onImgTouch)
				img.addEventListener(AEvent.RELEASE, onImgTouch)
				img.addEventListener(AEvent.MOVE, onImgTouch)
				img.addEventListener(AEvent.OVER, onImgTouch)
				img.addEventListener(AEvent.LEAVE, onImgTouch)
				img.addEventListener(AEvent.CLICK, onImgTouch)
			}
			
			this.group.addEventListener(AEvent.PRESS, onLayerTouch)
			this.group.addEventListener(AEvent.RELEASE, onLayerTouch)
			this.group.addEventListener(AEvent.MOVE, onLayerTouch)
			this.group.addEventListener(AEvent.OVER, onLayerTouch)
			this.group.addEventListener(AEvent.LEAVE, onLayerTouch)
			this.group.addEventListener(AEvent.CLICK, onLayerTouch)
			
			this.group.world.addEventListener(AEvent.PRESS, onWorldTouch)
			this.group.world.addEventListener(AEvent.RELEASE, onWorldTouch)
			this.group.world.addEventListener(AEvent.MOVE, onWorldTouch)
			this.group.world.addEventListener(AEvent.OVER, onWorldTouch)
			this.group.world.addEventListener(AEvent.LEAVE, onWorldTouch)
			this.group.world.addEventListener(AEvent.CLICK, onWorldTouch)
		}
		
	}
	
	
	
	private var img:ImageAA
	private var mFusion:FusionAA
	
	
	private function onImgTouch(e:AEvent):void {
		trace("Img: " + e.type)
	}
	
	private function onLayerTouch(e:AEvent):void {
		trace("Layer: " + e.type)
	}
	
	private function onWorldTouch(e:AEvent):void {
		trace("World: " + e.type)
	}
	
	private function onCollision( localX:Number, localY:Number, node:NodeAA ) : Boolean {
		if (Math.sqrt((localX - 110) * (localX - 110)  + (localY - 110)  * (localY - 110)) < 50) {
			return true
		}
		return false
	}
}
}